package com.example.customview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/8/30.
 */

public class CanvasPathView extends View {
    public CanvasPathView(Context context) {
        super(context);
    }

    public CanvasPathView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = new Paint();
        //如何需要绘制path的话，需要设置paint的Style为STROKE
        paint.setStyle(Paint.Style.STROKE);
        //复杂的线条需要通过path来绘制
        Path path = new Path();
        //移动接下来要绘制的内容的起点位置
        path.moveTo(50,50);
        //直线
        path.lineTo(100,100);
        //二阶贝塞尔曲线
        path.quadTo(200,200,300,100);
        canvas.drawPath(path,paint);
    }
}
